package com.accounting.services.endpoints;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import com.accounting.services.AccountService;
import com.accounting.ws.Account;
import com.accounting.ws.accountservice.AccountDetailsRequest;
import com.accounting.ws.accountservice.AccountDetailsResponse;

@Endpoint
public class AccountServiceEndpoint {
	

	private static final String TARGET_NAMESPACE="http://com/accounting/ws/accountservice";
	
	@Autowired
	@Qualifier("AccountServiceImpl")
	private AccountService accountservice;
	
	@PayloadRoot(localPart="AccountDetailsRequest", namespace=TARGET_NAMESPACE)
	public @ResponsePayload AccountDetailsResponse getAccountDetails(@RequestPayload AccountDetailsRequest request){
	
		AccountDetailsResponse response = new AccountDetailsResponse();
		Account account =accountservice.getAccountDetails(request.getAccountNumber());
		response.setAccountDetails(account);
		
		return response;
	}
}
